package com.sijiao.difflog.entity;

import com.sijiao.difflog.cache.LogDB;
import com.sijiao.difflog.util.BeanUtil;

import java.util.concurrent.Callable;

public class LogTask implements Callable<LogResult> {
    private Object original;
    private Object result;
    private String bizName;

    public LogTask(Object original, Object result, String bizName) {
        this.original = original;
        this.result = result;
        this.bizName = bizName;
    }

    @Override
    public LogResult call() throws Exception {
        String logJson = BeanUtil.createLogJson(bizName, original, result);
        LogDB.insert(logJson);

        return new LogResult(0,"success");
    }
}
